<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>投票活动列表</title>
    <#include "/common/link.ftl">

</head>
<body class="hold-transition skin-black sidebar-mini">
<div class="wrapper">
    <#include "/common/navbar.ftl">

    <#assign currentMenu="activity"/>

    <#include "/common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>投票活动列表</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/xxxx/list" method="post"  style="margin-top: 20px">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive">
                    <table class="table table-hover table-bordered table-striped">
                        <thead>
                        <tr>
                            <th>编号</th>
                            <th>投票主题</th>
                            <th>投票类型</th>
                            <th>投票状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#list pageInfo.list as a>
                            <tr>
                                <td>${a_index+1}</td>
                                <td>${a.title}</td>
                                <td>${((a.type==0)?string('单选','多选'))!}</td>
                                <td>${(a.status?string('投票中','停止投票'))!}</td>
                                <td>

                                    <a href="#"  class="btn btn-info btn-xs btn-input" data-id="${a.id}" data-status="${a.activeStatus}">
                                        <span class="glyphicon glyphicon-arrow-right" ></span> 投票
                                    </a>

                                </td>
                            </tr>
                        </#list>
                        </tbody>
                    </table>
                    <#include "/common/page.ftl" >
                </div>
            </div>
        </section>
    </div>
    <#include "/common/footer.ftl" >
</div>

<script>
    $('.btn-input').click(function () {
        let status = $(this).data('status');
        let id = $(this).data('id');
        if(status){
            Swal.fire({
                title: '温馨提示',
                text: "你已经投过票了,请不要重复投票",
                icon: 'warning',
                showCancelButton: true,
                confirmButtonText: '确认',
                cancelButtonText:'取消'
            }).then((result) => {
                if (result.value) { //如果上面点击确认
                    window.location.href="/choice/list?id="+id
                }
            })
        }else {
            window.location.href="/activityItem/list?id="+id
        }
    })

</script>



</body>
</html>
